package IO2;

import java.io.*;

/**
 * @description: IO_operation06
 * 字节数组流    不用关闭
 * 1.创建源 ：内部维护
 * 2.选择流 ：不关联源
 * 3.获取数据 toByteArray()  toString()
 * @date: 2019/12/17 13:39
 * @author: Vicuna
 */


public class IO_operation06 {
    public static void main(String[] args) {
        //1.创建源
        byte bt[] = "Hello World".getBytes();
        byte de[] = null;
        //2.选择流
        InputStream is = null;
        OutputStream os = null;
        try {
            is = new ByteArrayInputStream(bt);
            os = new ByteArrayOutputStream();
            //3.操作
            os.write(bt, 0, bt.length);
            os.flush();
            de=os.toString().getBytes();
            System.out.println(de.length+"--"+new String(de,0,de.length));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
